<?php
include_once "header.php";

if(isset($_GET['kd_kurir'])){
	
	$daftar_kurir = new Daftar_kurir();
	$kurir = $daftar_kurir->getById($_GET['kd_kurir']);

}

if(isset($_POST['ubah_kurir'])){

	if($_POST['kurir']!=""){
		
		$kurir=new Kurir();
		$kurir->setId($_POST['kd_kurir']);
		$kurir->setKurir($_POST['kurir']);
		$daftar_kurir = new Daftar_kurir();
		if($daftar_kurir->edit($kurir)==true){
				echo "<script>
						alert('Informasi: Data berhasil diubah');
						window.location.href='kurir.php';
					</script>";
			} else {
			
				echo "<script>
						alert('Informasi: Data gagal diubah');
					</script>";
				$daftar_kurir = new Daftar_kurir();
				$kurir = $daftar_kurir->getById($_POST['kd_kurir']);

			}
	}

}

?>

<div id="container">
	<div id="maincont">
		<?php include_once "menu_samping.php"; ?>
		<div id="mainright">
			<div id="title">
			Rekam kurir
			</div>
			<div id="body">
			<br/>
			<form name="form" method="POST" action="ubah_kurir.php">
			<input type="hidden" name="ubah_kurir">
			<input type="hidden" name="kd_kurir" value="<?php echo $kurir->getId(); ?>">
			<table cellspacing=0 cellpadding=4 width=100%>
			<tr>
				<td>Nama Kurir</td>
				<td>:</td>
				<td>
				<input type="text" name="kurir" value="<?php echo $kurir->getKurir();?>" size="32" maxlength="32">
				</td>
			
			</tr>
				
			</table>
			
			<br>
			<input type="submit" value="Simpan" onClick="return cekField();">
			<input type="button" value="Batal" onClick="window.location.href='kurir.php'">
			</form>
			
					
			</div>
        </div>
	</div>
</div>
<?php
	include_once "footer.php";
?>

<script type="text/javascript">
		
	
	function cekField(){
	var x = document.form.kurir.value;
	if (x==""){
		alert('Perhatian: Silahkan isi data terlebih dahulu!');
		return false;
	}
	}
</script>
